package level4.helpers
{
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	
	import level4.project.Project;
	/**
	 * xml文件助手
	 * */
	public class XmLHelper
	{
		
		/**
		 * 读入xml
		 * */
		public static function loadXml(url:String,completeFunction:Function):void{
			url = Project.UNDER_VERSION ? url + "?version="+Project.VERSION : url; 
			var l:URLLoader = new URLLoader(new URLRequest(url));
				l.addEventListener(Event.COMPLETE,onOk);
			
			///////////////////
			//闭包
			///////////////////
			function onOk(e:Event):void{
				l.removeEventListener(Event.COMPLETE,onOk);
				if(completeFunction != null){
					completeFunction(new XML(e.target.data));
				}
			}
		}
		
	}
}